Merge pull request #8643 from breadoven/abo_nav_yaw_refactor
[inav.git] / docs / development / Building in Windows 10 or 11 with MSYS2.md
blob1df77913b32a6a03cadc84007c9a22d18678e6f3
1 # General Info
3 This is a guide on how to use Windows MSYS2 distribution and building platform to build INAV firmware. This environment is very simple to manage and does not require installing docker for Windows which may get in the way of VMWare or any other virtualization software you already have running for other reasons. Another benefit of this approach is that the compiler runs natively on Windows, so performance is much better than compiling in a virtual environment or a container. You can also integrate with whatever IDE you are using to make code edits and work with github, which makes the entire development and testing workflow a lot more efficient. In addition to MSYS2, this build environment also uses Arm Embedded GCC tolkit from The xPack Project, which provides many benefits over the toolkits maintained by arm.com
5 Some of those benefits are described here:
7 https://xpack.github.io/arm-none-eabi-gcc/
9 ## Setting up build environment
11 Download MSYS2 for your architecture (most likely 64-bit)
13 https://www.msys2.org/wiki/MSYS2-installation/
15 Click on 64-bit, scroll all the way down for the latest release
17 pacman is the package manager which makes it a lot easier to install and maintain all the dependencies
19 ## Installing dependencies
21 Once MSYS2 is installed, you can open up a new terminal window by running:
23 "C:\msys64\mingw64.exe"
25 You can also make a shortcut of this somewhere on your taskbar, desktop, etc, or even setup a shortcut key to open it up every time you need to get a terminal window. If you right click on the window you can customize the font and layout to make it more comfortable to work with. This is very similar to cygwin or any other terminal program you might have used before
27 This is the best part:
28 ```
29 pacman -S git ruby make cmake gcc mingw-w64-x86_64-libwinpthread-git unzip wget
30 ```
32 Now, each release needs a different version of arm toolchain. To setup the xPack ARM toolchain, use the following process:
34 First, setup your work path, get the release you want to build or master if you want the latest/greatest
35 ```
36 mkdir /c/Workspace
37 cd /c/Workspace
38 # you can also check out your own fork here which makes contributing easier
39 git clone https://github.com/iNavFlight/inav
40 cd inav
41 ```
43 (Optional) Switch to a release instead of master
44 ```
45 git fetch origin
46 # on the next line, tags/5.0.0 is the release's tag, and local_5.0.0 is the name of a local branch you will create.
47 # tags can be found on https://github.com/iNavFlight/inav/tags as well as the releases page
48 git checkout tags/5.0.0 -b local_5.0.0
49 # you can also checkout with a branch if applicable:
50 # git checkout -b release_5.1.0 origin/release_5.1.0
51 ```
52 Now create the build and xpack directories and get the toolkit version you need for your INAV version
53 ```
54 mkdir build
55 cd build
56 mkdir /c/Workspace/xpack
57 cd /c/Workspace/xpack
58 cat /c/Workspace/inav/cmake/arm-none-eabi-checks.cmake | grep "set(arm_none_eabi_gcc_version" | cut -d\" -f2
59 ```
60 This will give you the version you need for any given release or master branch. You can get to all the releases here and find the version you need
62 https://github.com/xpack-dev-tools/arm-none-eabi-gcc-xpack/releases/
63 ```
64 # for INAV version 5.0.0, toolchain version needed is 10.2.1
65 wget https://github.com/xpack-dev-tools/arm-none-eabi-gcc-xpack/releases/download/v10.2.1-1.1/xpack-arm-none-eabi-gcc-10.2.1-1.1-win32-x64.zip
66 unzip xpack-arm-none-eabi-gcc-10.2.1-1.1-win32-x64.zip
67 ```
68 This is important, put the toolkit first before your path so that it is  picked up ahead of any other versions that may be present on your system
69 ```
70 export PATH=/c/Workspace/xpack/xpack-arm-none-eabi-gcc-10.2.1-1.1/bin:$PATH
71 cd /c/Workspace/inav/build
72 ```
73 You may need to run rm -rf * in build directory if you had any failed previous runs now run cmake
74 ```
75 # while inside the build directory
76 cmake ..
77 ```
78 Once that's done you can compile the firmware for your flight controller
79 ```
80 make DALRCF405
81 ```
82 To get a list of available targets in INAV, see the target src folder
83 [https://github.com/tednv/inav/tree/master/src/main/target](https://github.com/inavflight/inav/tree/master/src/main/target)
85 The generated hex file will be in /c/Workspace/inav/build folder
87 At the time of writting this document, I believe this is the fastest, easiest, and most efficient Windows build environment that is available. I have used this approach several years ago and was very happy with it building INAV 2.1 and 2.2, and now I'm getting back into it so figured I would share my method